package flight2;

import java.rmi.*;
import javax.naming.*;

public class SimpleClient{
  public static void main(String[] args){
    String url="rmi://localhost/";
    try{
      Context namingContext=new InitialContext();
      FlightFactory factory=(FlightFactory)                           namingContext.lookup(url+"FlightFactory");

      Flight flight1 = factory.getFlight("795");
      flight1.setOrigin("Shanghai");
      flight1.setDestination("Beijing");
      System.out.println("Flight "+flight1.getFlightNumber()+":");
      System.out.println("From "+flight1.getOrigin()+" to "+
                                        flight1.getDestination());
      factory.setFlightOrigin(flight1);
      //factory.setName2();
      System.out.println("From "+flight1.getOrigin());
      
      
    }catch(Exception e){
       e.printStackTrace();
    }
  }
}



